package com.sys.tdhclient.client;

import com.sys.tdhclient.operate.HdfsOperate;
import com.sys.tdhclient.prop.FileProps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Properties;

import static com.sys.tdhclient.prop.FileProps.confFilePath;

/**
 * 启动客户端并加载配置文件
 */
public class InitClient {
    //日志打印
    private static final Logger LOG = LoggerFactory.getLogger(InitClient.class);
    private Properties  properties=null;
    //启动客户端
    public  Properties init() {
        try {
            //加载配置文件
            FileProps fileProps = new FileProps();
            properties = fileProps.initProperties();
            String hdfshome = properties.getProperty("hdfs_home");
            String userPrincipal = properties.getProperty("userPrincipal");
            System.out.println("hdfshome========================="+hdfshome);
            System.out.println("userPrincipal===================="+userPrincipal);
        } catch (Exception e) {
            LOG.error("配置文件加载错误", e);
        }
        try {
            LOG.info("进行集群认证.");
            System.getProperty("user.dir");
            HdfsOperate hdfsOperate = new HdfsOperate();
            hdfsOperate.initHdfs(confFilePath );
        } catch (Exception e) {
            LOG.error("服务启动失败：", e);
        }
        return properties;
    }

}
